package com.lkx.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lkx.dao.ApiSubjectMapper;
import com.lkx.domain.ApiSubject;
import com.lkx.service.ApiSubjectService;
import com.lkx.util.PageModule;

@Service
public class ApiSubjectServiceImpl implements ApiSubjectService {
    private Logger logger = LoggerFactory.getLogger(ApiSubjectServiceImpl.class);
    @Autowired
    private ApiSubjectMapper apiSubjectMapper;
    @Override
    public int add(ApiSubject model) {
        int num = 0;
        try {
            num = apiSubjectMapper.insert(model);
        } catch (Exception e) {
            logger.error("ApiSubjectServiceImpl add : " + e.getMessage());
        }
        return num;
    }

    @Override
    public PageModule list(Long userid) {

        PageModule module = new PageModule();
        try {
            List<ApiSubject> list = new ArrayList<ApiSubject>();

            list = apiSubjectMapper.selectByUserId(userid);
            if (list != null && list.size() > 0) {
                module.setStatus(true);
                module.setList(list);
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
        return module;
    }

}
